﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EntityModel;
using Common;
namespace Services
{
    public class BrandService
    {
        #region***属性数据***

        ShopDbEntities bdContext = DbContextHelper.GetCurrentDbContext();


        #endregion

        #region 获取所有分类

        /// <summary>
        /// 获取所有分类
        /// </summary>
        /// <returns></returns>
        ///  PagedList<Brand>
        ///  
        public IQueryable<Brand> GetAllList()
        {
            return bdContext.Brands.OrderByDescending(c => c.Id);
        }

        #endregion

        #region 获取所有显示分类

        /// <summary>
        /// 获取所有显示分类
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Brand> GetList()
        {
            return bdContext.Brands.Where(c => c.Status == (int)EnumModel.Status.Show).OrderByDescending(c => c.DisplayOrder);
        }
        #endregion

        #region 新增数据

        public void Create(Brand model)
        {
            bdContext.Brands.AddObject(model);
            bdContext.SaveChanges();
        }
        #endregion
    }
}
